﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：MenuConfigurationInfo
// 文件功能描述：菜单配置业务逻辑层
//
// 
// 创建标识：2012-05-14 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class MenuConfigurationInfo
    {
        /// <summary>
        /// 菜单配置编号
        /// </summary>
        public int MenuConId
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单配置日期
        /// </summary>
        public DateTime MenuConDate
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单名称
        /// </summary>
        public string MenuName
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单类型
        /// </summary>
        public int MenuType
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单类型名称
        /// </summary>
        public string MenuTypeName
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单单价
        /// </summary>
        public decimal MenuPrice
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单备注
        /// </summary>
        public string MenuRemarks
        {
            get;
            set;
        }
        /// <summary>
        /// 菜单编号
        /// </summary>
        public int MenuId
        {
            get;
            set;
        }
        /// <summary>
        /// 操作员
        /// </summary>
        public string Operator
        {
            get;
            set;
        }
        /// <summary>
        /// 食堂编号
        /// </summary>
        public int NodeID
        {
            get;
            set;
        }
        /// <summary>
        /// 食堂名称
        /// </summary>
        public string Nodename
        {
            get;
            set;
        }
        /// <summary>
        /// 餐次编号
        /// </summary>
        public int PeriodCode
        {
            get;
            set;
        }
        /// <summary>
        /// 餐次名称
        /// </summary>
        public string PeriodName
        {
            get;
            set;
        }

        private DataAccessMenuConfiguration dar;
        private int MenuConcount;
        public int _MenuConcount
        {
            get { return MenuConcount; }
        }
        public MenuConfigurationInfo(bool isgetcount)
        {
            dar = new DataAccessMenuConfiguration();
            if (isgetcount)
            {
                MenuConcount = GetMenuConcount();
            }
        }
        public MenuConfigurationInfo()
        { }

        /// <summary>
        /// 获取菜单配置数量
        /// </summary>
        /// <returns></returns>
        private int GetMenuConcount()
        {
            return dar.GetMenuConcount();
        }

        /// <summary>
        /// 获取菜单配置数量
        /// </summary>
        /// <returns></returns>
        public int GetMenuConcount(string where)
        {
            return dar.GetMenuConcount(where);
        }

        /// <summary>
        /// 获取菜单配置信息（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<MenuConfigurationInfo> SelMenuConInfo(int pagesize, int startindex, string strquery)
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            MenuConfigurationInfo meninfo;
            DataSet ds = dar.SelMenuConInfo(pagesize, startindex, strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                meninfo = new MenuConfigurationInfo()
                {
                    MenuConId = Convert.ToInt32(item["MenuConId"]),
                    MenuConDate = Convert.ToDateTime(item["MenuConDate"]),
                    MenuTypeName = item["MenuTypeName"].ToString(),
                    MenuName = item["MenuName"].ToString(),
                    MenuPrice = Convert.ToDecimal(item["MenuPrice"]),
                    Nodename = item["Nodename"].ToString(),
                    PeriodName = item["PeriodName"].ToString()
                };
                menlist.Add(meninfo);
            }
            return menlist;
        }

        public IList<MenuConfigurationInfo> SelLeftBox(string strquery)
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            MenuConfigurationInfo meninfo;
            DataSet ds = dar.SelLeftBox(strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                meninfo = new MenuConfigurationInfo()
                {
                    MenuId = Convert.ToInt32(item["MenuId"]),
                    MenuName = item["MenuName"].ToString()
                };
                menlist.Add(meninfo);
            }
            return menlist;
        }

        public int SaveMenuConAdd(MenuConfigurationInfo men, string[] smenall)
        {
            object[] obj = new object[] { men.MenuConDate, men.Operator, men.NodeID, men.PeriodCode };
            return dar.SaveMenuConAdd(obj, smenall);
        }

        public int SaveMenuConEdit(MenuConfigurationInfo men, string[] smenall)
        {
            object[] obj = new object[] { men.MenuConDate, men.Operator, men.NodeID, men.PeriodCode };
            return dar.SaveMenuConEdit(obj, smenall);
        }

        /// <summary>
        /// 删除菜单配置
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public int DeleteMenuCon(string id)
        {
            return dar.DeleteMenuCon(id);
        }

        public string ExcelDataSource(string filepath, string sheetname, string Operator)
        {
            return dar.ExcelDataSource(filepath, sheetname, Operator);
        }

        public IList<MenuConfigurationInfo> SelRightBoxEdit(string Date, string ID)
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            MenuConfigurationInfo meninfo;
            DataSet ds = dar.SelRightBoxEdit(Date, ID);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                meninfo = new MenuConfigurationInfo()
                {
                    MenuId = Convert.ToInt32(item["MenuId"]),
                    MenuName = item["MenuName"].ToString()
                };
                menlist.Add(meninfo);
            }
            return menlist;
        }

        public DataSet SelEdit(string Date, string ID)
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            DataSet ds = dar.SelEdit(Date, ID);
            return ds;
        }

        public IList<MenuConfigurationInfo> SelNodeID()
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            MenuConfigurationInfo meninfo;
            DataSet ds = dar.SelNodeID();
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                meninfo = new MenuConfigurationInfo()
                {
                    NodeID = Convert.ToInt32(item["NodeID"]),
                    Nodename = item["Nodename"].ToString()
                };
                menlist.Add(meninfo);
            }
            return menlist;
        }

        public IList<MenuConfigurationInfo> SelPeriodCode()
        {
            IList<MenuConfigurationInfo> menlist = new List<MenuConfigurationInfo>();
            MenuConfigurationInfo meninfo;
            DataSet ds = dar.SelPeriodCode();
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                meninfo = new MenuConfigurationInfo()
                {
                    PeriodCode = Convert.ToInt32(item["PeriodCode"]),
                    PeriodName = item["PeriodName"].ToString()
                };
                menlist.Add(meninfo);
            }
            return menlist;
        }
    }
}
